﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:clr="clr-namespace:System;assembly=mscorlib" xmlns:clr2="clr-namespace:System.Collections;assembly=mscorlib" xmlns:local="clr-namespace:WPG" xmlns:data="clr-namespace:WPG.Data" xmlns:converters="clr-namespace:WPG.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">

	<!-- WPG Expander ToggleButton -->
	<ControlTemplate x:Key="ExpanderToggleButton" TargetType="{x:Type ToggleButton}">
		<Grid>
			<Rectangle Margin="0,0,0,0" x:Name="Rectangle" Fill="Transparent" />
			<Path HorizontalAlignment="Center" x:Name="Up_Arrow" VerticalAlignment="Center" Fill="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type local:PropertyGrid}, ResourceId=GlyphBrush}}" Data="M 0 0 L 4 4 L 8 0 Z" RenderTransformOrigin="0.5,0.5">
				<Path.RenderTransform>
					<TransformGroup>
						<ScaleTransform ScaleX="1" ScaleY="1" />
						<SkewTransform AngleX="0" AngleY="0" />
						<RotateTransform Angle="-90" />
						<TranslateTransform X="0" Y="0" />
					</TransformGroup>
				</Path.RenderTransform>
			</Path>
			<Path Visibility="Collapsed" HorizontalAlignment="Center" x:Name="Down_Arrow" VerticalAlignment="Center" Fill="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type local:PropertyGrid}, ResourceId=GlyphBrush}}" Data="M 0 4 L 4 0 L 8 4 Z" RenderTransformOrigin="0.5,0.5">
				<Path.RenderTransform>
					<TransformGroup>
						<ScaleTransform ScaleX="1" ScaleY="1" />
						<SkewTransform AngleX="0" AngleY="0" />
						<RotateTransform Angle="135" />
						<TranslateTransform X="0" Y="0" />
					</TransformGroup>
				</Path.RenderTransform>
			</Path>
		</Grid>
		<ControlTemplate.Triggers>
			<Trigger Property="IsChecked" Value="true">
				<Setter Property="Visibility" Value="Visible" TargetName="Down_Arrow" />
				<Setter Property="Visibility" Value="Collapsed" TargetName="Up_Arrow" />
				<Setter Property="OpacityMask" TargetName="Down_Arrow" Value="#FF000000" />
			</Trigger>
		</ControlTemplate.Triggers>
	</ControlTemplate>

	<!-- WPG Expander Style -->
	<Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type local:PropertyGrid}, ResourceId=ExpanderStyle}" TargetType="{x:Type Expander}">
		<Setter Property="Padding" Value="0" />
		<Setter Property="Background" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type local:PropertyGrid}, ResourceId=ExpanderBackgroundBrush}}" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Expander}">
					<Grid>
						<Grid.RowDefinitions>
							<RowDefinition Height="Auto" />
							<RowDefinition Height="*" x:Name="ContentRow" />
						</Grid.RowDefinitions>
						<Border Grid.Row="0" x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="LightGray">
							<Grid>
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="20" />
									<ColumnDefinition Width="*" />
								</Grid.ColumnDefinitions>
								<ToggleButton Template="{StaticResource ExpanderToggleButton}" IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" OverridesDefaultStyle="True" />
								<ContentPresenter Grid.Column="1" Margin="1" RecognizesAccessKey="True" ContentSource="Header" />
							</Grid>
						</Border>
						<Border Visibility="Collapsed" Grid.Row="1" x:Name="ExpandSite" Background="LightGray" Padding="10 0 0 0">

							<Border Background="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type local:PropertyGrid}, ResourceId=ExpanderBackgroundBrush}}" BorderThickness="0" Margin="0" Padding="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
								<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Focusable="false" />
							</Border>

						</Border>
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="IsExpanded" Value="True">
							<Setter Property="Visibility" Value="Visible" TargetName="ExpandSite" />
						</Trigger>
						<Trigger Property="IsEnabled" Value="False">
							<Setter Property="Background" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type local:PropertyGrid}, ResourceId=DisabledBackgroundBrush}}" TargetName="Border" />
							<Setter Property="BorderBrush" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type local:PropertyGrid}, ResourceId=DisabledBorderBrush}}" TargetName="Border" />
							<Setter Property="Foreground" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type local:PropertyGrid}, ResourceId=DisabledForegroundBrush}}" />
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
		<Setter Property="Foreground" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type local:PropertyGrid}, ResourceId=PropertiesForegroundBrush}}" />
	</Style>

</ResourceDictionary>